<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Test Create New Windows</title>
</head>

<body bgcolor="#FFFFFF">
    <div align="center">
         <h1>Create Windows</h1>
         <h4>
             <a href="#" id="topLeftWin">top left</a>
             <a href="#" id="topRightWin">top right</a>
             <br/>
             <a href="#" id="bottomLeftWin">bottom left</a>
             <a href="#" id="bottomRightWin">bottom right</a>
             <br/>
              <a href="#" id="closeWin">Close Windows</a>
        </h4>
    </div>
    <script type="text/javascript">
        var newWindow = null;
        window.onload = newWinLinks;

        function newWinLinks(){
            for(var i=0;i<document.links.length;i++){
                document.links[i].onclick = chgWindowState;
            }
        }

        function windowOpen(){
            if(newWindow && !newWindow.closed){
                return true;
            }
            return false;
        }

        function chgWindowState(){
            if(this.id == "closeWin"){
                if(windowOpen())
                    newWindow.close();
                else
                    alert("Windows isn't open!");
                return false;
            }
            if(this.id != "closeWin"){
                if(windowOpen()){
                    alert("Window is already open!");
                    return false;
                }
            }

            var topPos = (this.id.indexOf("bottom") == -1)?0:screen.availHeight -200;
            var leftPos = (this.id.indexOf("Right") == -1)?0:screen.availWidth - 300;

            newWindow = window.open("","newWin","toolbar,location=yes,width=300,height=200,left="+leftPos+",top="+topPos);
            return false;
        }



    </script>
</body>
</html>